﻿<UserControl x:Class="TimeSplicerModule.Views.ApplicationRoleView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Width="700" Height="600">

    <Grid VerticalAlignment="Top" HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="60" />
        </Grid.RowDefinitions>

        <Border VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5">
            <controls:MetroAnimatedSingleRowTabControl>
                <TabItem Header="Role Info">
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150" />
                            <ColumnDefinition Width="225" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <!-- Name -->
                        <Border Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Name:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBox Text="{Binding Path=Name}" Width="200" />
                        </Border>



                        <!-- Description -->
                        <Border Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Description:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBox Text="{Binding Path=Description}" Width="200" />
                        </Border>



                        <!-- Heiracrhy -->
                        <Border Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Hierarchy:" />
                        </Border>

                        <Border Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <TextBox Text="{Binding Path=Hierarchy}" />
                        </Border>

                        <!-- Is Active -->
                        <Border Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5">
                            <TextBlock Text="Is Active:" />
                        </Border>


                        <Border Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
                            <CheckBox IsChecked="{Binding Path=IsActive}" />
                        </Border>
                    </Grid>
                </TabItem>
                
                <TabItem Header="Role Permissions">
                    <Border VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5">
                        <DataGrid Name="permissionsGrid" ItemsSource="{Binding Path=Permissions}"
                                  AutoGenerateColumns="False"
                                  CanUserAddRows="False"
                                  CanUserDeleteRows="False">

                            <DataGrid.Columns>
                                <!--<DataGridTextColumn Header="ID" Binding="{Binding Path=ApplicationRolePermissionGuid}" />-->
                                <DataGridTextColumn Header="Application Item" Binding="{Binding Path=Item.Name}" />
                                
                                <DataGridTemplateColumn x:Name="Permissions" Header="Permissions" Width="150">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate >
                                            <ComboBox ItemsSource="{Binding Path=ApplicationPermissions}"
                                                      DisplayMemberPath="Name"
                                                      SelectedValuePath="ApplicationPermissionGuid"
                                                      SelectedValue="{Binding Path=ApplicationPermissionGuid, UpdateSourceTrigger=PropertyChanged}">
                                                
                                            </ComboBox>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                    </Border>
                </TabItem>
            </controls:MetroAnimatedSingleRowTabControl>
        </Border>

        <!-- Save, exit -->
        <Border Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center">
            <StackPanel Orientation="Horizontal">
                <Button Name="saveButton" Content="Save" Width="100" Height="25" Click="saveButton_Click" />
                <Button Name="saveExitButton" Content="Save &amp; Exit" Width="100" Height="25" Click="saveExitButton_Click"  Margin="15,0,0,0" />
                <Button Name="cancelButton" Content="Cancel" Width="100" Height="25" Click="cancelButton_Click"  Margin="15,0,0,0" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
